// ============================================================================
//
// Copyright (C) 2006-2007 Dengues
//
// Google Group: http://groups.google.com/group/dengues
// QQ Group: 24885404
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
// ============================================================================
package org.dengues.core.components;

import org.dengues.core.process.ICompConnection;
import org.dengues.core.process.ICompNode;
import org.dengues.core.property.EParameterFieldCategory;
import org.dengues.core.property.EPropertyCategory;
import org.dengues.model.database.AbstractDBObject;

/**
 * Qiang.Zhang.Adolf@gmail.com class global comment. Detailled comment <br/>
 * 
 * $Id: Dengues.epf 2008-1-7 qiang.zhang $
 * 
 */
public class NodePropertyParameter implements Cloneable {

    private String[] itemNames;

    private String[] itemDisplayNames;

    private Object[] itemValues;

    private String itemDefault;

    private boolean isRequired;

    private boolean isReadOnly;

    private boolean isBaseSchema;

    private int nbLines;

    private String repositoryValue;

    private String context;

    private ICompNode node;

    private ICompConnection connection;

    private String name;

    private String field;

    private boolean isShow;

    private int nbRow;

    private String displayName;

    private EPropertyCategory propertyCategory;

    private EParameterFieldCategory fieldCategory;

    private AbstractDBObject abstractDBObject;

    private Object value;

    /**
     * Qiang.Zhang.Adolf@gmail.com NodePropertyParameter constructor comment.
     */
    public NodePropertyParameter() {
        this.node = null;
        this.abstractDBObject = null;
        this.connection = null;
    }

    public NodePropertyParameter(ICompNode node) {
        this();
        this.node = node;
    }

    public NodePropertyParameter(ICompConnection connection) {
        this();
        this.connection = connection;
    }

    public NodePropertyParameter(AbstractDBObject child) {
        this();
        this.abstractDBObject = child;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public boolean isShow() {
        return isShow;
    }

    public void setShow(boolean isShow) {
        this.isShow = isShow;
    }

    public int getNbRow() {
        return nbRow;
    }

    public void setNbRow(int nbRow) {
        this.nbRow = nbRow;
    }

    public EParameterFieldCategory getFieldCategory() {
        return fieldCategory;
    }

    public void setFieldCategory(EParameterFieldCategory fieldCategory) {
        this.fieldCategory = fieldCategory;
        this.field = fieldCategory.getName();
    }

    public EPropertyCategory getPropertyCategory() {
        return propertyCategory;
    }

    public void setPropertyCategory(EPropertyCategory propertyCategory) {
        this.propertyCategory = propertyCategory;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    /**
     * Getter for node.
     * 
     * @return the node
     */
    public ICompNode getNode() {
        return this.node;
    }

    /**
     * Getter for isRequired.
     * 
     * @return the isRequired
     */
    public boolean isRequired() {
        return this.isRequired;
    }

    /**
     * Sets the isRequired.
     * 
     * @param isRequired the isRequired to set
     */
    public void setRequired(boolean isRequired) {
        this.isRequired = isRequired;
    }

    /**
     * Getter for isReadOnly.
     * 
     * @return the isReadOnly
     */
    public boolean isReadOnly() {
        return this.isReadOnly;
    }

    /**
     * Sets the isReadOnly.
     * 
     * @param isReadOnly the isReadOnly to set
     */
    public void setReadOnly(boolean isReadOnly) {
        this.isReadOnly = isReadOnly;
    }

    /**
     * Getter for nbLines.
     * 
     * @return the nbLines
     */
    public int getNbLines() {
        return this.nbLines;
    }

    /**
     * Sets the nbLines.
     * 
     * @param nbLines the nbLines to set
     */
    public void setNbLines(int nbLines) {
        this.nbLines = nbLines;
    }

    /**
     * Getter for repositoryValue.
     * 
     * @return the repositoryValue
     */
    public String getRepositoryValue() {
        return this.repositoryValue;
    }

    /**
     * Sets the repositoryValue.
     * 
     * @param repositoryValue the repositoryValue to set
     */
    public void setRepositoryValue(String repositoryValue) {
        this.repositoryValue = repositoryValue;
    }

    /**
     * Getter for context.
     * 
     * @return the context
     */
    public String getContext() {
        return this.context;
    }

    /**
     * Sets the context.
     * 
     * @param context the context to set
     */
    public void setContext(String context) {
        this.context = context;
    }

    /**
     * Getter for itemDefault.
     * 
     * @return the itemDefault
     */
    public String getItemDefault() {
        return this.itemDefault;
    }

    /**
     * Sets the itemDefault.
     * 
     * @param itemDefault the itemDefault to set
     */
    public void setItemDefault(String itemDefault) {
        this.itemDefault = itemDefault;
    }

    /**
     * Getter for itemValues.
     * 
     * @return the itemValues
     */
    public Object[] getItemValues() {
        return this.itemValues;
    }

    /**
     * Sets the itemValues.
     * 
     * @param itemValues the itemValues to set
     */
    public void setItemValues(Object[] itemValues) {
        this.itemValues = itemValues;
    }

    /**
     * Getter for itemNames.
     * 
     * @return the itemNames
     */
    public String[] getItemNames() {
        return this.itemNames;
    }

    /**
     * Sets the itemNames.
     * 
     * @param itemNames the itemNames to set
     */
    public void setItemNames(String[] itemNames) {
        this.itemNames = itemNames;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#clone()
     */
    @Override
    public NodePropertyParameter clone() {
        NodePropertyParameter parameter = null;
        try {
            parameter = (NodePropertyParameter) super.clone();
            if (getItemNames() != null) {
                parameter.setItemNames(getItemNames().clone());
            }
            if (getItemValues() != null) {
                parameter.setItemValues(getItemValues().clone());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return parameter;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuffer s = new StringBuffer();
        s.append("Name: " + getName() + "->"); //$NON-NLS-1$ //$NON-NLS-2$
        s.append("Value" + getValue() == null ? "" : getValue().toString()); //$NON-NLS-1$ //$NON-NLS-2$
        return s.toString();
    }

    public AbstractDBObject getAbstractDBObject() {
        return abstractDBObject;
    }

    /**
     * Getter for itemDisplayNames.
     * 
     * @return the itemDisplayNames
     */
    public String[] getItemDisplayNames() {
        return this.itemDisplayNames;
    }

    /**
     * Sets the itemDisplayNames.
     * 
     * @param itemDisplayNames the itemDisplayNames to set
     */
    public void setItemDisplayNames(String[] itemDisplayNames) {
        this.itemDisplayNames = itemDisplayNames;
    }

    /**
     * Getter for isBaseSchema.
     * 
     * @return the isBaseSchema
     */
    public boolean isBaseSchema() {
        return this.isBaseSchema;
    }

    /**
     * Sets the isBaseSchema.
     * 
     * @param isBaseSchema the isBaseSchema to set
     */
    public void setBaseSchema(boolean isBaseSchema) {
        this.isBaseSchema = isBaseSchema;
    }

}
